$(function() {
	
	var c=new CustomersComponent($("#customers"));

    c.loadAllData();

	
	$('#modal_add').on('hide.bs.modal', function () {
	   $("#a_name").val("");
       $("#a_sex").val("");
       $("#a_sal").val("");
       $("#a_birth").val("");
   
	});
	
	$('#modal_update').on('hide.bs.modal', function () {
		$("#u_id").val("");
		$("#u_name").val("");
        $("#u_sex").val("");
        $("#u_sal").val("");
        $("#u_birth").val("");
	});
		
	$("#a_sumbit").on("click",function () {

		var name = $("#a_name").val();
        var sex = $("#a_sex").val();
        var sal = $("#a_sal").val();
        var birth=$("#a_birth").val();
		var customer={
			"name":name,"sex":sex,"sal":sal,"birth":birth
		};
		c.addData(customer);
	});
	
	$("#u_sumbit").on("click",function () {
		var id = $("#u_id").val();
		console.log(id);
		var name = $("#u_name").val();
        var sex = $("#u_sex").val();
        var sal = $("#u_sal").val();
        var birth=$("#u_birth").val();
		var customer={
			"id":id,"name":name,"sex":sex,"sal":sal,"birth":birth
		};
		c.modifyData(customer);
	});
 	  
});
